let { ipcRenderer } = require('electron')

ipcRenderer.on('replyRender', (e, data) => {
  console.log('renderData', data)
})

window.onload = () => {
  let sendMesgBtn = document.querySelector('#sendMesg')
  let sendMesgSyncBtn = document.querySelector('#sendMesgSync')

  // 渲染进程给主进程发送消息  异步操作
  sendMesgBtn.onclick = () => {
    ipcRenderer.send('sendMain', {
      id: '12456',
      content: '渲染进程给主进程发送的消息'
    })
  }

  // 渲染进程给主进程发送消息  异步操作
  sendMesgSyncBtn.onclick = () => {
    let syncData = ipcRenderer.sendSync('sendMainSync', {
      id: '12456',
      content: '渲染进程给主进程发送的同步消息'
    })

    console.log('sync data render', syncData)
  }

}